<?php

class Img extends CWidget
{
    public $size = '';
    public $oRow = array();
    public $long = false;
    public $addSize = true;

	private $_path = '';

    public function init()
    {}

    public function run()
    {
	    if($this->oRow)
	    {
		    $path = $this->oRow->path . ($this->size ? $this->size .'-' : '') . $this->oRow->file;

		    $this->_path = ($this->long ? 'http://'.Yii::app()->params['host'] : '') . $path;

		    if($this->addSize && file_exists(PUBLIC_PATH . $path))
		    {
			    $info = getimagesize(PUBLIC_PATH . $path);
			    if(isset($info[3]))
			        $this->_path .= '" '. rtrim($info[3], '"');
		    }
	    }


    }

    public function __toString()
    {
        return $this->_path;
    }
}
